
<?php

$cn=new ChuyenNganh();
$dscn=$cn->ds();
$hv=new HocVi();
$dshv=$hv->ds();
$tt=new TinhTrangGV();
$dstt=$tt->ds();
$cv=new ChucVu();
$dscv=$cv->ds();
$gv= new GiangVien();
$gt=new GioiTinh();
$dsgt=$gt->ds();
if($_SERVER['REQUEST_METHOD']=='POST'){
				
				

				$ds=$_POST['dschucvu'];

				$index=0;

				$dsgvcv=array();

				foreach($ds as $key){
					$pos=new ChucVu();
					$pos->getInfo($key);
					$dsgvcv[$index]=$pos;
					$index++;
				}

			 	foreach ($dsgvcv as $key){
			 		echo "<br>".$key->getMa();
			 	}

			 		$gv->setMa($_POST['txtma']);
					$gv->setTen($_POST['txtten']);
					$gv->setNgaySinh(NgayThang::dinhDangNhap($_POST['txtngaysinh']));
					$gv->setEmail($_POST['txtmail']);
					$gv->setTel($_POST['txttel']);
					$gv->setNamCongTac($_POST['txtnamct']);
					$cn->getInfo($_POST['slCN']);
					$gv->setChuyenNganh($cn);
					
					$gv->setDSChucVu($dsgvcv);

					$hv->getInfo($_POST['slHV']);
					$gv->setHocVi($hv);
					$tt->getInfo($_POST['slTTGV']);
					$gv->setTinhTrangGV($tt);
					$gv->setHinhAnh("");
					$gv->setHeSoPhanCong(5);
					$gv->setMatKhau("");
					$gv->setMobile($_POST['txtmobile']);
					$gv->setCmnd($_POST['txtcmnd']);
					$gt->getInfo($_POST['slGT']);
					$gv->setGioiTinh($gt);
					$gv->them();
					header('location:index.php');
				

}

/**if($_SERVER['REQUEST_METHOD']=='POST'){
	if (!empty($_FILES['fhinhanh']['name'])) {
		if ((($_FILES["fhinhanh"]["type"] == "image/gif")
			|| ($_FILES["fhinhanh"]["type"] == "image/jpeg")
			|| ($_FILES["fhinhanh"]["type"] == "image/jpg")
			|| ($_FILES["fhinhanh"]["type"] == "image/pjpeg")
			|| ($_FILES["fhinhanh"]["type"] == "image/x-png")
			|| ($_FILES["fhinhanh"]["type"] == "image/png")))
			{
				if (((($_FILES["fhinhanh"]["size"])/1024)/1024)<1) {
					$gv->setMa($_POST['txtma']);
					$gv->setTen($_POST['txtten']);
					$gv->setNgaySinh(NgayThang::dinhDangNhap($_POST['dschucvu'];$_POST['txtngaysinh']));
					$gv->setEmail($_POST['txtmail']);
					$gv->setTel($_POST['txttel']);
					$gv->setNamCongTac($_POST['txtnamct']);
					$cn->getInfo($_POST['slCN']);
					$gv->setChuyenNganh($cn);
					$cv->getInfo($_POST['slCV']);
					$gv->setChucVu($cv);
					$hv->getInfo($_POST['slHV']);
					$gv->setHocVi($hv);
					$tt->getInfo($_POST['slTTGV']);
					$gv->setTinhTrangGV($tt);
					$gv->setHinhAnh(Upload::uploadFile('fhinhanh',SRV_ROOT."manager/upload/hoso/giangvien/"));
					$gv->setHeSoPhanCong(5);
					$gv->setMatKhau("");
					$gv->them();
					header('location:index.php');
				}
				else {
					$error= "<p id=\"thongbao\"><img src=\"".ICON_DIR.'/error.gif'."\" alt=\"\"> Dung lượng hình không quá 1 MB";
					$div="<div class=\"error\">". $error."</div>";
					echo $div;
				} 
			}
		else {
			$error="<p id=\"thongbao\"> <img src=\"".ICON_DIR.'/error.gif'."\" alt=\"\"> Vui lòng chọn file hình ảnh (jpg,jpeg,png)";
			$div="<div class=\"error\">". $error."</div>";
			echo $div;
			}
		}
		else
		{
					$gv->setMa($_POST['txtma']);
					$gv->setTen($_POST['txtten']);
					$gv->setNgaySinh(NgayThang::dinhDangNhap($_POST['txtngaysinh']));
					$gv->setEmail($_POST['txtmail']);
					$gv->setTel($_POST['txttel']);
					$gv->setNamCongTac($_POST['txtnamct']);
					$cn->getInfo($_POST['slCN']);
					$gv->setChuyenNganh($cn);
					$cv->getInfo($_POST['slCV']);
					$gv->setChucVu($cv);
					$hv->getInfo($_POST['slHV']);
					$gv->setHocVi($hv);
					$tt->getInfo($_POST['slTTGV']);
					$gv->setTinhTrangGV($tt);
					$gv->setHinhAnh("");
					$gv->setHeSoPhanCong(5);
					$gv->setMatKhau("");
					$gv->them();
					header('location:index.php');
		}
}
**/
?>
<div class="thongtin_giangvien">
<form action="" method="POST" name="frmGV" enctype="multipart/form-data">
<legend>FORM THÊM GIẢNG VIÊN</legend>
		<table cellpadding="0px" cellspacing="0px`">
			<tr>
				<td>Mã giảng viên:</td>
				<td>
					<input type="text" name="txtma" id="text" class="textnhap" > <br />
				</td>
				</tr>
				<tr>
					<td>Họ và tên: </td>
					<td>
						<input type="text" name="txtten" id="text" class="textnhap" ><br />
					</td>
				</tr>
				<tr>
					<td>Giới tính</td>
					<td>
						<?php 
						echo Common::createSelect($dsgt,"slGT");
						?>
					</td>
				</tr>
				<tr>
					<td>Ngày sinh: (d/m/y):</td>
					<td>
						<input type="text" name="txtngaysinh" id="text" class="textnhap" ><br />
					</td>
				</tr>
				<tr>
					<td>CMND:</td>
					<td><input type="text" name="txtcmnd" id="text" class="textnhap" ><br /></td>
				</tr>
				<tr>
					<td>Mobile:</td>
					<td><input type="text" name="txtmobile" id="text" class="textnhap" ><br /></td>
				</tr>
				<tr>
					<td>Tel:</td>
					<td><input type="text" name="txttel" id="text" class="textnhap" ><br /></td>
				</tr>
				<tr>
					<td>Email:</td>
					<td>
						<input type="text" name="txtmail" id="text" class="textnhap" ><br />
					</td>
				</tr>
				<tr>
				<td>Năm công tác:</td>
				<td>
					<input type="text" name="txtnamct" id="text" class="textnhap" > <br />
				</td>
				</tr>
				<tr>
					<td>Chuyên Ngành</td>
					<td>
						<?php 
						echo Common::createSelect($dscn,"slCN");
						?>
					</td>
				</tr>
				<tr>
					<td>Chức vụ:</td>
					<td>
						<div id="dschucvu">

						<?php
							foreach ($dscv as $key){
								echo "<input type=\"checkbox\" name=\"dschucvu[]\" value=\"".$key->getMa()."\"> ".$key->getTen()."<br/>";
							}

						?>
							
						</div>
					</td>
				</tr>
				<tr>
					<td>Học vị:</td>
					<td>
						<?php 
						echo Common::createSelect($dshv,"slHV");
						?>
					</td>
				</tr>
				<tr>
					<td>Tình Trạng: </td>
					<td>
						<?php 
						echo Common::createSelect($dstt,"slTTGV");
						?>
					</td>
				</tr>
				<tr>
					<td>Hình Ảnh: </td>
					<td><input type="file" name="fhinhanh" id="text" class="textnhap" ><br /></td>
				</tr>
				<tr>
					<td colspan="2">
						<input type="submit" value="Thêm" id="btthem2">
					</td>
				</tr>			
</form>
</table>
</div>

